<?php

declare(strict_types=1);

namespace App\Admin\Service\Setting;

use DI\DependencyException;
use DI\NotFoundException;
use Newbie\Generator\TableGenerator;
use function App\Setting\Service\make;

/**
 * 数据表设计服务
 * Class TableService
 * @package App\Setting\Service
 */
class TableService {
    /**
     * 获取表前缀信息
     * @return string
     */
    public function getTablePrefix (): string {
        return env('DB_PREFIX', '');
    }

    /**
     * 创建数据表
     * @param array $data
     * @return bool
     * @throws DependencyException
     * @throws NotFoundException
     */
    public function createTable (array $data): bool {
        return container()->get(TableGenerator::class)->setTableInfo($data)->createTable();
    }
}